package view;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

/**
 * Menu principal de l'application
 * @author Lefevre, Thoue
 */
public class BarMenu extends JMenuBar{
    private Fenetre fenetre;
    private JMenu menuFichier;
    private JMenu menuContact;
    private JMenu menuParametre;
    /**
     * Constructeur
     * @param mafenetre lien vers la fenetre principal
     */
    public BarMenu(final Fenetre mafenetre){
        this.fenetre = mafenetre;
        this.setBackground(Color.LIGHT_GRAY);
        
        menuFichier = new JMenu("Fichier");
        menuFichier.setBackground(Color.LIGHT_GRAY);
        JMenuItem fermer = new JMenuItem("Fermer");
        fermer.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
               System.exit(0);
            }
        });
        menuFichier.add(fermer);
        this.add(menuFichier);
        
        menuContact = new JMenu("Contact");
        menuContact.setBackground(Color.LIGHT_GRAY);
        JMenuItem addContact = new JMenuItem("Ajouter Contact");
        addContact.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
               fenetre.getContactFrame().setVisible(true);
            }
        });
        menuContact.add(addContact);
        this.add(menuContact);
        
        menuParametre = new JMenu("Parametres");
        menuParametre.setBackground(Color.LIGHT_GRAY);
        JMenuItem parametreSon = new JMenuItem("Parametres de Son");
        parametreSon.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
               fenetre.getParamFrame().setVisible(true);
            }
        });
        menuParametre.add(parametreSon);
        this.add(menuParametre);
    }
}